import Vue from 'vue'
import App from './App.vue'
import maxios from 'maxios'
Vue.config.productionTip = false
Vue.prototype.maxios = maxios

function Mvuex(obj){
	let {state,mutations,actions,getters} = obj;
	let store = {
		state:state,
		dispatch:null,
		commit:null,
		getters:null
	}
	Vue.prototype.$store = store
	bindData();
	function bindData(){
		new Vue({
		created(){
			Vue.prototype.$store.state = this;
			Vue.prototype.$store.commit = commit;
			Vue.prototype.$store.dispatch = dispatch;
		    Vue.prototype.$store.getters = mgetters;
		},
		data:state,
		
	})
	}
	
	function commit(...args){
		var mutation = args[0];
		var elargs = args.slice(1)
		mutations[mutation](Vue.prototype.$store.state,...elargs)
	}
	
	function dispatch(...args){
		var action = args[0];
		var elargs = args.slice(1)
		actions[action]({
			state:Vue.prototype.$store.state,
			dispatch:dispatch,
			commit:commit,
			getters:mgetters
		},elargs)
	}
	
	function mgetters(...args){
		var mgetter = args[0];
		return getters[mgetter](Vue.prototype.$store.state)
	}
	
	
	
}





 new Vue({
  render: h => h(App),
  mvuex:new Mvuex({
	  state:{
		  name:'lee'
	  },
	  actions:{
		  cg:function(context){
			  context.commit('cg')
		  }
	  },
	  mutations:{
		  cg:function(state){
			  state.name = 'kkkkkd'
		  }
	  },
	  getters:{
		  getname:function(state){
			  return state.name
		  }
	  }
  })
}).$mount('#app')
